package com.example.chatgpt.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;

import com.example.chatgpt.entity.MessageInfo;

import java.util.List;

@Dao
public interface MessageDao {

    //添加
    @Insert
    void insertMessage(MessageInfo... messageInfos);

    //查询全部
    @Query("SELECT * FROM message")
    List<MessageInfo> queryAll();

    //根据消息内容删除
    @Query("DELETE FROM message WHERE message =:message")
    void deleteByMessage(String message);

    //删除全部
    @Delete
    void deleteAll(MessageInfo... messageInfos);

    //根据时间和用户查询
    @Query("SELECT * FROM message WHERE date =:date and user =:user")
    List<MessageInfo> queryByDate(String date, String user);

    //根据时间和用户删除
    @Query("DELETE FROM message WHERE date = :date and user =:user")
    void deleteByDate(String date, String user);

    //删除用户聊天记录
    @Query("DELETE FROM message WHERE user = :user")
    void deleteByUser(String user);
}
